home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Utilities / Print / Postscript / DistillPS 3.0b1 / still.ps < prev   
Encoding:
Text File  |  1989-02-28  |  60.8 KB  |  5 lines  |  [TEXT/unix]

  1. %!PS-Adobe-2.1
  2. %%Title: still.ps
  3. %%Creator: Glenn Reid, Adobe Systems <adobe!greid@decwrl.dec.com>
  4. %%CreationDate:    greid Wed Jul  6 18:02:53 1988 EDIT: Tue Feb 28 10:24:40 1989
  5. %%VMUsage: 40696
  6. %%EndComments
  7.  
  8. % Notice: Copyright 1988 1989 Adobe Systems Incorporated.  All Rights Reserved.
  9.  
  10.  
  11. /adobe_distill 155 200 add dict def    % 155 required by still.ps
  12. /adobe_still_version ((V 1.0d release 9 edit 06)) def
  13.  
  14. % options:
  15. /debug true def            % generate debugging messages
  16. /messages false def        % generate more debugging messages (verbose!)
  17. /trace true  def        % print tracing messages like "page: 3"
  18. /substitutefonts true def    % substitute fonts if guess_font fails....
  19. /includeuserfonts true def    % copy embedded user-defined fonts to output?;
  20. /printpages false def        % do you want the pages to print?
  21. /optimize true def        % optimize "show" to "widthshow", etc.
  22. /tolerance .05 def        % for "approximately equal to" operations
  23. /cachedir 60 dict def        % how many font dicts to cache (optimization)
  24.  
  25. % HOW TO USE: [see section below]
  26. %
  27. % OVERVIEW:
  28. %    This is a meta-utility program that "distills" any PostScript
  29. %    language program into a simpler one.  The resulting program
  30. %    will print exactly the same page as the original, but all
  31. %    unnecessary execution overhead is eliminated and the file is
  32. %    clean, uniform, and fast.
  33. %
  34. % RELEASE NOTES: [recent changes and details]
  35. %    First public release: 2/10/89
  36. %    Second release: 2/17/89
  37. %        - reimplemented guess_font routines
  38. %        - added support for color; not careful about RGB->CMYK->RGB
  39. %        - added selective printing of pages during distill
  40. %    Third release: ???
  41. %        - fixed color-induced [major efficiency loss] bug
  42. %        - produces %%BoundingBox and %%PageBoundingBox info (atend)
  43. %        - works better (bugs fixed) on rotated (landscape) documents
  44. %
  45. % MANY USES:
  46. %    * If you archive documents in PostScript format, they can be
  47. %      made as compact and efficient as possible by distilling them.
  48. %    * As a development tool, you can see what your program is
  49. %      really doing, and how simple and fast the driver could be.
  50. %    * Distilled files can be used as an interchange format,
  51. %      since arbitrary PostScript files can be converted to this
  52. %      uniform representation.
  53. %    * If your program can parse these files, then any arbitrary
  54. %      PostScript program can be used as input after distilling.
  55. %    * Many others.
  56. %
  57. % FEATURES:
  58. %    * correctly distills arbitrarily complex PostScript programs
  59. %    * output is universal, simple, and in default user coordinates
  60. %    * handles "charpath", "image", "imagemask", "awidthshow", etc.
  61. %    * correctly follows "save", "restore", "gsave", "grestore"
  62. %    * re-encodes fonts automatically to match application encoding
  63. %    * reduces prologue size to only about 25-30 lines
  64. %    * For machine-generated code:
  65. %        * output files are almost always SMALLER than original files
  66. %         * output files are almost always FASTER than original files
  67. %    * optimizes "show" to use "widthshow" whenever possible.
  68. %    * uses save/restore at page boundaries
  69. %    * observes structuring conventions and page independence
  70. %    * caches font dictionaries instead of repeating "findfonts"
  71. %    * output is normally VERY, VERY fast.
  72. %
  73. % HOW TO USE:
  74. %    This program redefines a bunch of operators, and is invoked
  75. %    with the word "distill".  This file has to precede the job it is
  76. %    distilling, and you have to invoke it by calling "distill".
  77. %
  78. %    PRINTERS:
  79. %        In general, start with this file (still.ps), add the word
  80. %        "distill" at the end (to invoke the procedure), and tack
  81. %        any PostScript language file onto the end.  Send this to
  82. %        your favorite PostScript printer with an appropriate
  83. %        end-of-file indication at the end.  Results will
  84. %        be returned across communication channel.
  85. %
  86. %    INTERPRETERS: if you have an interpreter with a file system
  87. %        handy, first type "(still.ps) run" to load this file, then
  88. %        distill your file like this: "(prog.ps) distill".  It will
  89. %        write the results in "prog.psx" (appends an x to the file
  90. %        name you give it).
  91. %    MACINTOSH: I have written a small Mac utility that is called
  92. %        "DistillPS" (an adaptation of "SendPS") that will perform the
  93. %        above PRINTER steps for you.  If you are an Adobe registered
  94. %        developer, you can get a copy directly from Adobe.
  95. %
  96. % BACKGROUND
  97. % The basic idea is to execute the input file completely, with all of
  98. % the painting operators redefined.  When one of these operators is
  99. % called by the client program, the distillery will write the
  100. % path the output file (with all coordinates normalized to the default
  101. % userspace coordinate system).
  102. % The routines in this file are broken down into several areas.  Most
  103. % of them are concerned with writing things to the output file,
  104. % actually, although there are two other interesting areas.  The first
  105. % are the graphics state procedures, which attempt to keep track of the
  106. % graphics state and, when a painting op is called, it writes out any
  107. % changes to the graphics state since the last time it was called.  This
  108. % keeps each painting op from having to write gstate itself.  The other
  109. % interesting procs are simply the redefinitions of the painting ops
  110. % themselves.
  111. %
  112. % KNOWN COMPATIBLE PROGRAMS
  113. % The following applications have been tested (with some version of the
  114. % driver, at least), successfully:
  115. %    Lotus Manuscript
  116. %    Macintosh "LaserPrep" (all documents, I think)
  117. %    DEC's VaxDocument
  118. %    Scribe
  119. %    PageMaker
  120. %    Frame Maker
  121. %    Adobe Illustrator
  122. %    TranScript (ditroff and enscript drivers)
  123. %
  124. % KNOWN PROBLEMS:
  125. %    Clipping isn't handled correctly.
  126. %
  127. %    Rotated text with "charpath" isn't working quite right.
  128. %
  129. %    I'm not convinced that the bounding box for images is right.
  130. %
  131. %    Hand-written PostScript language programs (especially those
  132. %    that take advantage of looping constructs) will get BIGGER
  133. %    when you distill them, because the Distillery unrolls all loops.
  134. %    It is really intended for machine-generated files, but it should
  135. %    still work on programs tightly coded by hand (like Cookbook
  136. %    examples).
  137. %
  138. %    Use of the "put" and "putinterval" operators to overwrite
  139. %    string bodies can confuse the optimization technique.  If you
  140. %    see strange output (wrong characters printed, especially),
  141. %    try changing "/optimize true def" to "/optimize false def"
  142. %    at the very beginning of this program.
  143. %
  144. %    Programs that use the "transform" operator to make resolution-
  145. %    rounding decisions may have the output file bound to a specific
  146. %    resolution.  The last ProcSet (called "hacks") redefines a few
  147. %    operators to try to work around this.  Output file is still
  148. %    device-independent in any case, but might look different.
  149. %
  150. %    Distillery relies on bug in save/restore related to string bodies
  151. %    to preserve some information across save/restore.  Localized
  152. %    to the "adobe_staticvar" procedure set.
  153. %
  154. %    In order to optimize re-encoding of fonts, the distillery takes
  155. %    an educated guess that the first re-encoded font it sees will
  156. %    have a representative encoding vector ("stdvec").  If this
  157. %    first font is not encounterd before other marks are made, the encoding
  158. %    vector cannot be produced in the %%BeginSetup section, and the still
  159. %    is forced to repeat the vector every time a font is used.  Work
  160. %    is in progress on a heuristic to improve this.
  161. %
  162. %       In order to avoid building up the dictionary stack during
  163. %       execution, all definitions are made in one dictionary
  164. %       (PROLOGUE) and it is not explicitly brought to the top of
  165. %       the dictionary stack for each operation (to avoid
  166. %       "dictstackoverflow" errors).  Most of the identifiers have
  167. %       been chosen to be reasonably unique, but there could be a
  168. %       conflict if user programs use the same names.
  169. %
  170. %    Sometimes generates unnecessarily verbose code in the presence
  171. %    of lots of save/restores in original file.  Try distilling the
  172. %    output a second time to improve this (like whiskey)....
  173. %
  174. %    Some of the ProcSets depend on each other in weird ways, which
  175. %    is definitely wrong, since only the script should depend on
  176. %    the procset definitions.  Eventually this will get fixed.
  177. %
  178. %    Does not always work correctly with user-defined fonts, especially
  179. %    those defined by the standard TeX driver (unfortunately).  In
  180. %    particular, TeX bitmap fonts that are defined and have characters
  181. %    added on the fly are almost impossible to make sense of with this
  182. %    distillery approach.
  183.  
  184. %%BeginProcSet: distill_defs 1.0 0
  185. /setpacking where { pop currentpacking true setpacking } if
  186. /firstmtx matrix currentmatrix def
  187.  
  188. /bdef { bind def } bind def
  189.  
  190. /ifnotdef { %def
  191.   % only does the "def" if the key has not already been defined:
  192.     1 index where { pop pop pop }{ def } ifelse
  193. } bdef
  194.  
  195. /*flushfile /flushfile load ifnotdef
  196.  
  197. printpages not { %if
  198.     /showpage { erasepage initgraphics } bind def
  199. } if
  200.  
  201. /currentcmykcolor where { pop }{ %else
  202.     /currentcmykcolor { %def
  203.         currentrgbcolor 3 { 1 exch sub 3 1 roll } repeat 0
  204.     } bind def
  205. } ifelse
  206.  
  207. /setpacking where { pop setpacking } if
  208. %%EndProcSet
  209.  
  210. %%BeginProcSet: Adobe_staticvar 1.0 0
  211.     % this procedure set implements the "magic" stuff to hide numbers
  212.     % and other things where they will not be subject to save/restore
  213.     /magicval { 8 string } bdef
  214.     /hideval { %def    % /name int :    % "hideval" uses save/restore bug!
  215.     exch load dup 0 (\040\040\040\040\040\040\040\040) putinterval
  216.     exch (\040\040\040\040\040\040\040\040) cvs
  217.     dup length 8 exch sub exch putinterval
  218.     } bdef
  219.     /magicbool { 5 string } bdef
  220.     /hidebool { %def    % /name int :    % "hideval" uses save/restore bug!
  221.     exch load dup 0 (\040\040\040\040\040) putinterval
  222.     exch (\040\040\040\040\040) cvs 0 exch putinterval
  223.     } bdef
  224.     /cvnum { cvx exec } bdef    % makes hidden val back into an integer
  225.     /cvbool { cvx exec } bdef    % makes hidden val back into a boolean
  226.     /hidefontname { %def
  227.     % hides a font name in a string body, for use in %%DocumentFonts
  228.     scratch cvs
  229.     % look to see if it is already in the docfonts string:
  230.     % lots of hacks to search for (FontName\n), not just (FontName)
  231.     save    % cause we're using memory for temporary string
  232.         adobe_distill begin
  233.         1 index length 1 add string /tmpstring exch def
  234.         tmpstring dup length 1 sub (\040) 0 get put
  235.         tmpstring 0 3 index putinterval
  236.         pagefonts tmpstring search {pop pop pop false}{pop true} ifelse
  237.         docfonts tmpstring search {pop pop pop false}{pop true}ifelse
  238.         end
  239.     3 -1 roll restore        % roll save object past booleans
  240.  
  241.     % first deal with docfonts, then with pagefonts booleans
  242.     { %ifelse
  243.         exch    % extra boolean for page fonts
  244.         dup dfontcount cvnum 1 index length add 1 add
  245.         docfonts length lt {
  246.         dup docfonts exch dfontcount cvnum exch putinterval
  247.         length 1 add dfontcount cvnum add /dfontcount exch hideval
  248.         docfonts dfontcount cvnum 1 sub (\040) putinterval
  249.         }{ %else
  250.         pop (% No more room for fonts in document font list\n) d=
  251.         } ifelse
  252.         messages { %if
  253.         (document fonts: ) print
  254.         docfonts 0 dfontcount cvnum getinterval = flush
  255.         } if
  256.         exch % page font boolean still on stack, under "dup"ed string
  257.     }{ } ifelse
  258.     { %ifelse
  259.         pfontcount cvnum 1 index length add 1 add
  260.         pagefonts length lt {
  261.         dup pagefonts exch pfontcount cvnum exch putinterval
  262.         length 1 add pfontcount cvnum add /pfontcount exch hideval
  263.         pagefonts pfontcount cvnum 1 sub (\040) putinterval
  264.         }{ %else
  265.         pop (% No more room for fonts in page font list\n) d=
  266.         } ifelse
  267.         messages { %if
  268.         (page fonts: ) print
  269.         pagefonts 0 pfontcount cvnum getinterval = flush
  270.         } if
  271.     }{ pop } ifelse
  272.     } bdef
  273. %%EndProcSet: Adobe_staticvar 1.0 0
  274.  
  275. %%BeginProcSet: distill 1.0 0
  276. /setpacking where { pop currentpacking true setpacking } if
  277.  
  278. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  279.  
  280. % some variables
  281.     % magic variables depending on "hideval", not subject to save/restore
  282.     /pagecount magicval def    /pagecount 1 hideval
  283.     /beginsetup magicbool def    /beginsetup true hidebool
  284.     /lastshowpage magicbool def    /lastshowpage false hidebool
  285.     /begunpage magicbool def    /begunpage false hidebool
  286.  
  287.     /dfontcount magicval def     /dfontcount 0 hideval
  288.     /pfontcount magicval def    /pfontcount 0 hideval
  289.     /docfonts 40 30 mul string def        % room for 40 30-byte font names
  290.     /pagefonts 40 30 mul string def        % room for 40 30-byte font names
  291.     /LLx magicval def        /LLx 10000 hideval
  292.     /LLy magicval def        /LLy 10000 hideval
  293.     /URx magicval def        /URx -10000 hideval
  294.     /URy magicval def        /URy -10000 hideval
  295.     /docLLx magicval def    /docLLx 10000 hideval
  296.     /docLLy magicval def    /docLLy 10000 hideval
  297.     /docURx magicval def    /docURx -10000 hideval
  298.     /docURy magicval def    /docURy -10000 hideval
  299.  
  300.     /optim optimize def
  301.     /scratch 128 string def
  302.     /fontcount 0 def
  303.     /indentlevel 0 def
  304.     /ANYtype null def
  305.     /insideproc false def
  306.     /Dfont null def
  307.     /Ffont null def
  308.     /Fname null def
  309.     /lastshow false def
  310.     /imageproc null def
  311.     /imagematrix null def
  312.     /imagedepth null def
  313.     /imageheight null def
  314.     /imagewidth null def
  315.  
  316. % a few of them go into userdict:
  317. /cvp {
  318.     messages { % ifelse
  319.     (                     ) cvs print (\040) print
  320.     }{ pop } ifelse
  321. } bdef
  322. /pr= { messages { print }{ pop } ifelse } bdef
  323. /d= { messages { = }{ pop } ifelse } bdef
  324.  
  325. /distill {
  326.     adobe_distill begin
  327.     debug{(%!PS-Adobe-2.1 debug version ) print adobe_still_version == }if
  328.     userdict /orig_dictcount countdictstack put
  329.     count 0 eq { %ifelse
  330.         /OUTfile (%stdin) def
  331.         /fd (%stdout) (w) file def
  332.         initstill
  333.         writeprologue
  334.         initgstate
  335.         currentfile cvx exec
  336.         writetrailer
  337.     }{ %else
  338.         initgraphics
  339.         /saveall save def
  340.         /INfile exch def
  341.         /OUTfile INfile length 1 add string def
  342.         OUTfile 0 INfile putinterval
  343.         OUTfile dup length 1 sub (x) 0 get put
  344.         trace { (output file: ) print OUTfile = } if
  345.         /outfile OUTfile (w) file def
  346.         /fd /outfile load def
  347.         initstill
  348.         writeprologue
  349.         initgstate
  350.         debug { %ifelse
  351.             INfile run
  352.         }{ % else
  353.             { INfile run } stopped { % if
  354.              errordict begin $error begin
  355.                 (\n%%[Error: ) wout
  356.                 /errorname load =string cvs wout
  357.                 (; OffendingCommand: ) wout
  358.                 /command load =string cvs wout (]%%) wout writeNL
  359.                 (STACK:) writeop /ostack load type /arraytype eq {
  360.                 ostack { =string cvs writeop } forall
  361.                 } if
  362.                 fd systemdict /flushfile get exec
  363.                 handleerror
  364.             end end
  365.             } if
  366.         } ifelse
  367.         writetrailer
  368.         fd closefile
  369.         countdictstack orig_dictcount sub { end } repeat
  370.         clear
  371.         saveall { restore } stopped { %if
  372.         trace { (couldn't restore after distill.) = } if
  373.         } if
  374.     } ifelse
  375.    end
  376. } bdef
  377.  
  378. % the rest of them go in "adobe_distill"
  379. adobe_distill begin
  380. %     /stopped {
  381. %     (stopped: ) print dup ==
  382. %     exec false
  383. %     } bdef
  384.  
  385.     /initstill {
  386.     /beginsetup true hidebool
  387.     /lastshowpage false hidebool
  388.     /begunpage false hidebool
  389.     /pagecount 1 hideval
  390.     /STDvec 0 hideval
  391.     /PAGEvec 0 hideval
  392.     /dfontcount 0 hideval
  393.     /pfontcount 0 hideval
  394.     /LLx 10000 hideval  /LLy 10000 hideval
  395.     /URx -10000 hideval /URy -10000 hideval
  396.     /docLLx 10000 hideval  /docLLy 10000 hideval
  397.     /docURx -10000 hideval /docURy -10000 hideval
  398.     /SharedFontDirectory where { %ifelse
  399.         /SharedFontDirectory get
  400.     }{ /FontDirectory load } ifelse
  401.     /FontDirectory exch def
  402.     0 1 pagefonts length 1 sub { pagefonts exch 0 put } for
  403.     0 1 docfonts length 1 sub { docfonts exch 0 put } for
  404.     } bdef
  405.     debug { %if
  406.     /BB {
  407.         debug {
  408.         (% BBox: ) print
  409.         LLx print ( ) print LLy print ( ) print
  410.         URx print ( ) print URy print () = flush
  411.         (% DocBBox: ) print
  412.         docLLx print ( ) print docLLy print ( ) print
  413.         docURx print ( ) print docURy print () = flush
  414.         } if
  415.     } bdef
  416.     } if
  417.     /?box { %def    % X Y
  418.     dup URy cvnum gt { dup /URy exch cvi hideval } if
  419.     dup LLy cvnum lt { dup /LLy exch cvi hideval } if pop
  420.     dup URx cvnum gt { dup /URx exch cvi hideval } if
  421.     dup LLx cvnum lt { dup /LLx exch cvi hideval } if pop
  422.     } bdef
  423.     /doc?box {
  424.     dup docURy cvnum gt { dup /docURy exch cvi hideval } if
  425.     dup docLLy cvnum lt { dup /docLLy exch cvi hideval } if pop
  426.     dup docURx cvnum gt { dup /docURx exch cvi hideval } if
  427.     dup docLLx cvnum lt { dup /docLLx exch cvi hideval } if pop
  428.     } bdef
  429.     /pageBBox-docBBox {
  430.     LLx cvnum LLy cvnum doc?box
  431.     URx cvnum URy cvnum doc?box
  432.     } bdef
  433.     /writeRmove { %def
  434.     2 copy lineY sub exch lineX sub exch
  435.     dup 0.0 eq { pop writenum (x) writeop }{ %ifelse
  436.         1 index 0.0 eq { writenum (y) writeop pop }{ %ifelse
  437.         writepair (r) writeop
  438.         } ifelse
  439.     } ifelse
  440.     2 copy ?box
  441.     /lineY exch store /lineX exch store
  442.     } bdef
  443.     /writelines { %def
  444.     counttomark REPEAT_LINETO_THRESHOLD gt { % ifelse
  445.         counttomark /lcount exch store
  446.         lcount -2 2 { %for
  447.         dup /rcount exch store
  448.         -2 roll 2 copy lineY sub exch lineX sub exch 4 -2 roll
  449.         2 copy ?box
  450.         /lineY exch store /lineX exch store
  451.         rcount 2 roll
  452.         } for
  453.         lcount 2 idiv { writepair writeNL } repeat
  454.         lcount 2 idiv writenum (R) writeop
  455.     }{ % else
  456.         counttomark -2 2 { -2 roll writeRmove } for
  457.     } ifelse
  458.     } bdef
  459.     /writepath {
  460.     /closed false store
  461.     % optimize special case of just "moveto lineto stroke"
  462.     mark
  463.     % pathforall
  464.     { counttomark 2 gt { cleartomark false exit } if thruCTM true }
  465.     { counttomark 5 gt { cleartomark false exit } if thruCTM true }
  466.     { cleartomark false exit }
  467.     { cleartomark false exit }
  468.     pathforall { %ifelse
  469.         counttomark 5 ne { %ifelse
  470.         % degenerate case...
  471.         ischarpath counttomark 2 eq and {    % just moveto
  472.             2 copy ?box
  473.             writepair (m) writeop
  474.         } if
  475.         cleartomark
  476.         }{ %else
  477.         3 -1 roll pop
  478.         /?simplepath true store
  479.         simplepath astore pop
  480.         pop %mark
  481.         } ifelse
  482.     }{ %else
  483.         /?simplepath false store
  484.         mark
  485.         { % moveto
  486.         closed { (cp ) wout /closed false store } if
  487.         counttomark 2 gt { %if
  488.             counttomark 1 add 2 roll writelines 3 1 roll
  489.         } if
  490.         2 copy thruCTM /lineY exch store /lineX exch store
  491.         2 copy ?box
  492.         writeTpair (m) writeop
  493.         } % moveto proc
  494.         { %lineto proc
  495.         thruCTM count 490 gt { writelines } if
  496.         } % lineto
  497.         { % curveto
  498.         counttomark 6 gt { %if
  499.             counttomark 1 add 6 roll writelines 7 1 roll
  500.         } if
  501.         2 copy thruCTM /lineY exch store /lineX exch store
  502.         3 { %repeat
  503.             6 -2 roll 2 copy thruCTM
  504.             2 copy ?box
  505.             exch writenum writenum
  506.         } repeat (c) writeop 6 {pop} repeat
  507.         } % curveto
  508.         { % closepath
  509.         counttomark 0 gt { writelines } if
  510.         /closed true store
  511.         } % closepath
  512.         pathforall
  513.         counttomark 0 gt { writelines } if
  514.         pop %mark
  515.     } ifelse
  516.     } bdef
  517.     /hashpath { %def
  518.       % manufacture a [fairly] unique integer to represent a path:
  519.     -1                % initial value
  520.     { .5 add add 2 div add }    % moveto
  521.     { add sub }            % lineto
  522.     { add add sub add add add }    % curveto
  523.     { 1 add }            % closepath
  524.     pathforall
  525.     dup 100 lt { 10 mul truncate 10 div } if
  526.     } bdef
  527.     "hashencoding { %def
  528.    ñ  % manufacture a [f‰irly] unique integer for an encoding vector,
  529.       % by alternately adding then subtracting the length of the name.
  530.       % The alternation makes reordered lists with same names still come out
  531.       % with a different hash value (the "-1 exch" and the "mul" do this)
  532.     -1 exch 0 exch            % initial value: 0
  533.     { % forall
  534.         dup type /nametype eq { length }{ pop 1 } ifelse
  535.         2 index mul add    % multiply by 1 or -1 and add
  536.         exch -1 mul exch    % flip 1 and -1
  537.     } forall
  538.     exch pop            % get rid of -1, leave hash val
  539.     } bdef
  540.     /STDvec magicval def /STDvec 0 hideval
  541.     /PAGEvec magicval def /PAGEvec 0 hideval
  542.     /enc1 null def /enc2 nulÏ def
  543.   xø/diffencoding { %def
  544.     % check the "top128" boolean to see if itßs wort¡reencoding the‹:    /enc2ë∏xch store /enc1 exch st¯re    % eoc2 is tfle new oπ
  545.     [/
  546.         32 1=127 { %˜≈r                %%0 1 255S?
  547.         du¶/dup enf2 exch g|t exchoÌnc1 excl get
  548.     ± index ¯q { po¿ pop } f
  549.         }∫for
  550.     ]8   } b'ef
  551.     /8ndent %indentûevel { fd (  ) íritestrQ}  } ep}at } b|Âf
  552.     £A+ {∞`up load 1P∫dd sto≈e } b    ef
  553.     /-ØW{ dup Ëèad dmP 1 ge { ¿ sub } q stoRe } bdef
  554. O1nd %ad Ôe_diªtill
  555. &setΔ9cking w⁄ere Œƒpop setp⁄Oking } if
  556. %%∞ÓdProcSetêú%%BeÁinHrocS±x: distilQíwritetofile 1N0 0
  557. /setûNckin· where…aøpop curr¸∂tpac◊ing truø∏setpackinQ } iF
  558. /adobe≤distill du\ wher { popop }{ 165ø200 yd dictŒ—ef } ifelse
  559. adÂbe_dist‰Öl begij
  560.  ,  /wOitetrai¡år { %def    % :
  561.     ptackptrøÜ ne { {tÈckshoÜ’} if
  562.     
  563. gunpagkòcvbool ‰ %if
  564.     YB  lastsrowpageÍcvbool nt { %iÊi        ( /snlwpage ∫… def) witeop
  565. ôp   } if$        p¸gecountÚ!vnum scratch cVw wout 
  566. KENDPAGE\n) wouy
  567.         (H%PageTrailer) wìteop
  568.     õZ  (%%PageFontsÏ“) wout∞        pfontcountZcvnum 0 Fq { writeNL }{Ûñelse
  569.         pfontcount cvnuÓó200 lt „ %ifelse
  570.            pagefonts 0 pfontcount cvnum getinterval writ÷op
  571.         }{ %else
  572.             pag˙fonts (\040) seCrch not√{ writeop }{ %eåse
  573.             wÎuteop    % first one withoˆ the %%+
  574.             { %loop
  575.         °   search { (%%Æ ) wou@øwriteoå }{ %else
  576.                 (€L00) search { writeop pBs pop }~ pop } pfelse
  577.     º¥    exit
  578.                 } ifelse
  579. ˆ6    } looâ
  580.             } ifelseg~    } ifelse
  581.         0 1öpfontc_unt cvnuÌ { pagefonts ex‚h 0 put } for
  582.     /pfontcˇuntH0 hideval
  583. ß    } ifälse
  584.      ò  LLx 1R000 eq LLy 1000’ eq or
  585. û   URx…-10000 ù URy -\ä000 eq or or nOt {
  586.         (Z    PageoundingBoÒø ) wou˜          LLx cvnum ü
  587. itenum 9Ly cÓnum writeÖtm
  588.           5Rx cvçm writenV. URy cv≈um wrjtenum wr1•eNL
  589.         } ia≈        pagt|Box-docGBox
  590. ¢} if
  591.     (%%ï,ailer) writeh
  592.     (end %1ROLOGHE) writAp
  593.     (%%Pa    #s: ) wout ÑaC*count cvnäm writenum w^iteNL
  594.     (%%?oundiˆgBox: c wout
  595.       dÇcLLx cvnum w!¨tenum docLLy cnum writPnum
  596.      #docURx »vnum wriÈ2num dxcURy cvƒum writºúum wri†eNL
  597.     (%ƒXocumenFonts: )#wout
  598.     Ô#ontcount cvnum!0 eq { ïPiteNL }{ %else’        dfbqtcount ¨vnum v00 lt { áIfelse
  599.         docfonus 0 dfotcount cvnum geDinterva
  600. Fwriteop
  601.         }Í%else
  602.         docfonts (\040'≈search]åot { writeop }{ %else
  603.             writeop    % first one without the %%+
  604.             { %loop
  605.             search { (%%+ ) wout writeop }{ %else
  606.                 (\000) search { writeop pop pop }{ pop } ifelse
  607.                 exit
  608.             } ifelse
  609.             } loop
  610.         } ifelse
  611.         } ifelse
  612.     } ifelse
  613.     (%%EOF) writeop
  614.     } bdef
  615.     /writecomments { %def
  616.     fd (%!PS-Adobe-2.1\n) writestring
  617.     fd (%%Title: ) writestring fd OUTfile writestring fd (\n) writestring
  618.     fd (%%Creator: Glenn Reid and still.ps ) writestring
  619.     fd adobe_still_version writestring fd (\n) writestring
  620.     fd (%%BoundingBox: (atend)\n) writestring
  621.     fd (%%Pages: (atend)\n) writestring
  622.     fd (%%DâcumentProcSets: Adobe_distill 0.906\n) writestring
  623.     fd (%%EndComments\n) #ritestring
  624.     } bdef
  625.     /writeprologue { %def    % :
  626.     writecomments
  627.     mark
  628.     (%%BeginProcSet: Adobe_distill 0.906)
  629.     (/PROLOGU˙ 30 40 add dict def)
  630.     (  30 procedure entries + room for 40 cached font dictionaries)
  631.     ( PROLOGUE begin)
  632.     ( /clip { } def    % causes problems. remove if "clip" is needed)
  633.     ( /bdef { bind def } bind def    /ldef { load def } bdef)
  634.     ( /T { moveto show } bdef    /A { moveto ashow } bdef)
  635.     ( /W { moveto widthshow } bdef    /AW { moveto awidthshow } bdef)
  636.     ( /f /fill ldef            /R { { rlineto } repeat } bdef)
  637.     ( /r /rlineto ldef        /L { { lineto } repeat } bdef)
  638.     ( /m /moveto ldef        /l { moveto lineto stroke } bdef)
  639.     ( /x { 0 rlineto } bdef        /y { 0 exch rlineto } bdef)
  640.     ( /c /curveto ldef        /cp /closepath ldef)
  641.     ( /s /stroke ldef        /w /setlinewidth ldef)
  642.     ( /g /setgray ldef        /j /setlinejoin ldef)
  643.     ( /d /setdash ldef        /F /setfont ldef)
  644.     ( /C /setcmykcolor where { /setcmykcolor get }{ %ifelse)
  645.     (     { pop 3{1 exch sub 3 1 roll} repeat setrgbcolor } bind)
  646.     ( } ifelse def)
  647.     ( /MF { findfont exch makefont setfont } bdef)
  648.     ( /DF { findfont exch scalefont setfont currentfont def } bdef)
  649.     ( /BEGINPAGE { pop /pagesave save def } bdef)
  650.     ( /ENDPAGE { pop pagesave restore showpage } def)
  651.     ( /REMAP { %def)
  652.     (   FontDirectory 2 index known { pop pop pop } { %ifelse)
  653.     (     findfont begin currentdict dup length dict begin)
  654.     (       { 1 index /FID ne {def}{pop pop} ifelse } forall)
  655.     (       exch dup length 0 gt { /Encoding exch def }{ pop } ifelse)
  656.     (     currentdict end end definefont pop)
  657.     (   } ifelse)
  658.     ( } bdef)
  659.     ( /RECODE { %def)
  660.     (    3 -1 roll 1 index findfont /Encoding get 256 array copy exch)
  661.     (    0 exch { %forall)
  662.     (     dup type/nametype eq)
  663.     (    { 3 {2 index} repeat put pop 1 add }{ exch pop }ifelse)
  664.     (    } forall pop 3 1 roll REMAP)
  665.     ( } bdef)
  666.     ( end %PROLOGUE)
  667.     (%%EndProcSet: Adobe_distill 0.906)
  668.     (%%EndProlog)
  669.     (%%BeginSetup)
  670.     (PROLOGUE begin)
  671.     % write all the above strings to the output file:
  672.     counttomark -1 1 { %for
  673.         -1 roll fd exch writestring fd (\n) writestring
  674.     } for
  675.     fd systemdict /flushfile get exec
  676.     pop %mark
  677.     } bdef
  678.     /checksetup { %def
  679.     % called from "fontstate", "graphicstate", and "definefont"
  680.     beginsetup cvbool {
  681.         /beginsetup false hidebool
  682.         fd (\n%%EndSetup\n%%Page: 1 1\n) writestring
  683.         fd (%%PageFonts: (atend)\n) writestring
  684.         fd (%%PageBoundingBox: (atend)\n) writestring
  685.         fd (1 BEGINPAGE\n) writestring
  686.         /begunpage true hidebool
  687.         /fontcount 0 store
  688.     }{ %else
  689.         lastshowpage cvbool { %if
  690.         /lastshowpage false hidebool
  691.         /fontcount 0 store
  692.         writeNL (%%Page: ) wout
  693.         trace { (page: ) print pagecount cvnum == flush } if
  694.         /pagecount pagecount cvnum 1 add hideval
  695.         pagecount cvnum dup writenum writenum writeNL
  696.         (%%PageFonts: (atend)) writeop
  697.         (%%PageBoundingBox: (atend)) writeop
  698.         pagecount cvnum scratch cvs wout ( BEGINPAGE\n) wout
  699.         /begunpage true hidebool
  700.          % invalidate all remapped fonts, for page independence
  701.         FontDirectory { %forall
  702.             exch pop dup /FontInfo known { %ifelse
  703.             /FontInfo get dup /pleasemap known { %ifelse
  704.                 begin (Glenn Reid)
  705.                 pleasemap cvbool not {
  706.                     /pleasemap true hidebool
  707.                 } if pop
  708.                 end
  709.             }{ pop } ifelse
  710.             }{ pop } ifelse
  711.         } forall
  712.         % forcegstate
  713.         } if
  714.     } ifelse
  715.     } bdef
  716.     /writenamearray {        % [ /name ... ] :
  717.     fd ([) writestring
  718.     /indentlevel ++ fd (\n) writestring indent
  719.     /CNT 1 store
  720.     %| maintain CNT to count bytes.  wrap lines at a reasonable
  721.     %| place when writing out character names, to avoid long lines
  722.     { %forall
  723.         fd (/) writestring
  724.         dup type /nametype eq { scratch cvs }{ pop (.notdef) } ifelse
  725.         dup  length 1 add CNT add /CNT exch store  fd exch writestring
  726.         CNT 60 ge { /CNT 1 store fd (\n) writestring indent } if
  727.     } forall
  728.     /indentlevel -- fd (\n) writestring indent fd (]) writestring
  729.     } bdef
  730.     /writediffencoding {    % [ 32/name 37/etc ... ] :
  731.     fd ([) writestring
  732.     /indentlevel ++ fd (\n) writestring indent
  733.     /CNT 1 store
  734.     %| maintain CNT to count bytes.  wrap lines at a reasonable
  735.     %| place when writing out character names, to avoid long lines
  736.     { %forall
  737.         dup type /integertype eq { %ifelse
  738.         fd (\040) writestring
  739.         scratch cvs fd exch writestring /CNT CNT 4 add store
  740.         }{ %else
  741.         fd (/) writestring
  742.         dup type /nametype eq { scratch cvs }{ pop (.notdef) } ifelse
  743.         dup  length 1 add CNT add /CNT exch store  fd exch writestring
  744.         } ifelse
  745.         CNT 60 ge { /CNT 1 store fd (\n) writestring indent } if
  746.     } forall
  747.     /indentlevel -- fd (\n) writestring indent fd (]) writestring
  748.     } bdef
  749.  
  750.   % write numbers in various formats:
  751.  
  752.     /thruCTM { CTM transform } bdef
  753.     /dthruCTM { CTM dtransform } bdef
  754.     /XthruCTM { %def
  755.     dup CTM dtransform
  756.     rot not { pop }{ %else
  757.         2 copy gt { pop }{ exch pop } ifelse
  758.     } ifelse
  759.     } bdef
  760.  
  761.     /*writestring { %def
  762.     writestring fd *flushfile
  763.     } bdef
  764.     /shave { %def
  765.       % eliminate significant digits beyond .001; compensate for roundoff
  766.     dup type /realtype eq { %if
  767.         1000 mul truncate 1000 div
  768.     } if
  769.     } bdef
  770.     /writenum { % def        % num :
  771.     dup abs 0.001 le { pop 0 } if        % --> 0
  772.     dup dup cvi eq { cvi } if
  773.     fd exch scratch cvs writestring _space
  774.     } bdef
  775.     /writeprecisenum { % def        % num :
  776.     fd exch scratch cvs writestring _space
  777.     } bdef
  778.     /writeXnum { % def        % num :
  779.     CTM 0 get mul writenum
  780.     } bdef
  781.     /writeYnum { % def        % num :
  782.     CTM 3 get mul writenum
  783.     } bdef
  784.     /writeTpair { % def        % num1 num2 :
  785.     thruCTM exch
  786.     writenum writenum
  787.     } bdef
  788.     /writepair { % def        % num1 num2 :
  789.     exch writenum writenum
  790.     } bdef
  791.     /writenumarray {        % [ nums ] : 
  792.     fd ([) writestring
  793.     { writenum } forall
  794.     fd (] ) writestring
  795.     } bdef
  796.  
  797.   % write out names and strings:
  798.     /writeNL { fd (\n) writestring } bdef
  799.     /_space { fd (\040) writestring } bdef
  800.     /wout { % def        % (string) :
  801.      fd exch writestring
  802.     } bdef
  803.     /writestr { % def        % (string) :
  804.     fd exch writestring _space
  805.     } bdef
  806.     /writeop { %def        % (string) :
  807.     fd exch writestring writeNL
  808.     } bdef
  809.     /writePSstring { % def    % (string) :
  810.     fd (\() writestring dup length 75 gt exch
  811.     wordfix fd (\) ) writestring { writeNL } if % if length > 75 bytes
  812.     } bdef
  813.     /writename { % def        % name :
  814.     scratch cvs fd exch writestring  _space
  815.     } bdef
  816.     /writeRname { % def        % name :
  817.     (/) wout scratch cvs wout (R ) wout
  818.     } bdef
  819.     /checkallnames { %def    % proc :
  820.     { % forall
  821.         dup type /nametype ne { pop }{ %ifelse
  822.         dup systemdict exch known { pop }{ % ifelse
  823.             dup xcheck not { pop }{ %ifelse
  824.             dup load dup type /arraytype eq %
  825.                 { checkallnames }{ pop } ifelse
  826.             (userdict /) wout dup writename
  827.             load writeANY
  828.             (put) writeop
  829.             } ifelse
  830.         } ifelse
  831.         } ifelse
  832.     } forall
  833.     } bdef
  834.     /writeproc { %def
  835.     ({) writestr writeNL
  836.     insideproc exch /insideproc true store /indentlevel ++
  837.     dup type /arraytype eq 1 index type /packedarraytype eq or { % ifelse
  838.         dup length 20 lt { %ifelse
  839.         { writeANY } forall
  840.         }{ %else
  841.         { writeANY writeNL indent } forall
  842.         } ifelse
  843.     }{ %else
  844.         writename
  845.     } ifelse
  846.     /insideproc exch store /indentlevel --
  847.     indent (}) writestr
  848.     } bdef
  849.     /typedict 12 dict def
  850.     typedict begin
  851.     /stringtype { writePSstring } def
  852.     /arraytype { %def
  853.         dup xcheck { %ifelse
  854.         writeproc
  855.         }{ %else
  856.         /CNT 1 store
  857.         ([) writeop /indentlevel ++
  858.         { indent writeANY writeNL } forall
  859. %         { %forall
  860. %             writeANY /CNT ++ CNT 10 gt { %if
  861. %             /CNT 1 store writeNL indent
  862. %             } if
  863. %         } forall
  864.         /indentlevel -- indent (]) writeop
  865.         } ifelse
  866.     } bdef
  867.     /packedarraytype /arraytype load def
  868.     /dicttype { %def
  869.               % safety: 1 add (needed for User Fonts)
  870.         dup maxlength 1 add writenum (dict begin) writeop
  871.         { %forall
  872.         indent exch writeANY writeANY (def) writeop
  873.         } forall (currentdict end) writeop
  874.     } bdef
  875.     /integertype { writenum } def
  876.     /realtype { writenum } def
  877.     /nulltype { pop (null ) wout } def
  878.     /operatortype { %def
  879.         insideproc { %ifelse
  880.         writename
  881.         }{ %else
  882.         (/) wout writename (load) writestr
  883.         } ifelse
  884.     } bdef
  885.     /nametype { %def
  886.         dup xcheck not { (/) wout } if
  887.         writename
  888.     } bdef
  889.     end % typedict
  890.     /writeANY { %def 
  891.     dup type dup typedict exch known { %ifelse
  892.         typedict exch get exec
  893.     }{ %else
  894.         pop writename
  895.     } ifelse
  896.     } bdef
  897.     % The following writes an escaped string that may contain special chars.
  898.     % It regenerates the (\035string) notation.
  899.     /wordfix { %def        % (string) :
  900.     (\() search { %ifelse
  901.         rparenfix (\\\() wout pop wordfix
  902.     }{ rparenfix } ifelse
  903.     } bdef
  904.     /rparenfix { %def
  905.     (\)) search { %ifelse
  906.         binaryfix (\\\)) wout pop rparenfix
  907.     }{ binaryfix } ifelse
  908.     } bdef
  909.     /str1 1 string def
  910.     /longstr 1028 string def
  911.     /writetomark { %def
  912.     counttomark -1 0 { %for
  913.         longstr exch exch put
  914.     } for
  915.     } bdef
  916.     /binaryfix { %def
  917.     dup false exch { %forall
  918.         dup 128 gt 1 index 32 lt or { %ifelse
  919.         str1 exch 0 exch put pop true exit
  920.         }{ pop } ifelse
  921.     } forall
  922.     { %ifelse    % depending on whether num>128 was found
  923.         str1 search {
  924.         quotefix        % string previous to num>128
  925.         (\\) wout        % the backslash
  926.                     % write suspicious char as octal
  927.         0 get 8 scratch cvrs    % padding with leading 0 as needed
  928.         dup length 3 exch sub { (0) wout } repeat wout
  929.         binaryfix        % recurse on rest of string
  930.         }{
  931.         (ERROR: search lied in "binaryfix".) = flush stop
  932.         } ifelse
  933.     }{ quotefix } ifelse
  934.     } bdef
  935.     /quotefix { %def
  936.     (\\) search {  %ifelse
  937.         wout (\\\\) wout pop quotefix
  938.     }{ wout } ifelse
  939.     } bdef
  940.  
  941. end %adobe_distill
  942. /setpacking where { pop setpacking } if
  943. %%EndProcSet
  944.  
  945. %%BeginProcSet: distill_graphicstate 1.0 0
  946. % we don't want packed arrays for all these matrices; set packing later
  947. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  948. adobe_distill begin
  949.  
  950.   % define a bunch of state variables, then use "store" subsequently
  951.   % to write into them (to avoid currentdict problems).
  952.     /mtx matrix def
  953.     /tmpmtx matrix def
  954.     /fontmtx matrix def
  955.     /curfontmtx matrix def
  956.     /CTM matrix currentmatrix def
  957.     /currCTM matrix currentmatrix def
  958.     /compareCTM matrix currentmatrix def
  959.     /newCTM matrix def
  960.     /mtx1 0 def
  961.     /mtx2 0 def
  962.     /invmtx
  963.     tmpmtx currentmatrix matrix invertmatrix
  964.     def
  965.     /$normalize {
  966.     invmtx currCTM concatmatrix
  967.     } bind def
  968.     /rot false def
  969.     /gray currentgray def
  970.     currentcmykcolor
  971.     /colK exch def /colY exch def /colM exch def /colC exch def
  972.     /linewidth currentlinewidth def
  973.     /linecap currentlinecap def
  974.     /linejoin currentlinejoin def
  975.     /miterlimit currentmiterlimit def
  976.     /screenang null def
  977.     /screenfreq null def
  978.     /screenproc null def
  979.     /closed false def
  980.     currentdash /dashoff exch def /dasharray exch def
  981.     /pointX -1 def /pointY -1 def
  982.     /initfontscale matrix def
  983.     /fontscale initfontscale def
  984.     /0a 0 def /0b 0 def
  985.     /X1 0 def /X2 0 def
  986.     /origfontname null def
  987.     /currfontdict null def
  988.     /definefontname null def
  989.     /tempfontname /Courier def
  990.     /ischarpath false def
  991.     /currpath newpath hashpath def
  992.     /pathstr () def
  993.     /pathbool false def
  994.     /pathX 0 def /pathY 0 def
  995.     /lineX 0 def /lineY 0 def
  996.     /lcount 0 def /rcount 0 def
  997.     /REPEAT_LINETO_THRESHOLD 20 def    % point at which repeat loop is used
  998.     /currX -1 def /currY -1 def
  999.     /diffX 0 def
  1000.     /gstates 0 def
  1001.     /charpathgstate 0 def
  1002.     /CNT 0 def
  1003.     /showX null def /showY null def
  1004.     /currfont currentfont def
  1005.     /cliphash newpath hashpath def
  1006.     /?simplepath false def
  1007.     /simplepath [ 0 0 0 0 ] def
  1008.  
  1009. /setpacking where { pop currentpacking true setpacking } if
  1010.  
  1011.     /matrixeq { %def        % compares two matrices
  1012.     /mtx2 exch store
  1013.     /mtx1 exch store
  1014.     0 1 5 { %for
  1015.         dup mtx1 exch get
  1016.         exch mtx2 exch get eq
  1017.     } for
  1018.     5 { and } repeat
  1019.     } bdef
  1020.  
  1021.   % procedure definitions for state machinery ---------------
  1022.  
  1023.     /initgstate { %def
  1024.     gsave
  1025.         initgraphics
  1026.         tmpmtx currentmatrix compareCTM matrixeq not {
  1027.         /CTM mtx currentmatrix $normalize store
  1028.         compareCTM currentmatrix pop
  1029.         .345 dup 0 dtransform pop 0 idtransform
  1030.         pop ne dup /rot exch store not optimize and /optim exch store
  1031.         } if
  1032.         /gray currentgray store
  1033.         currentcmykcolor
  1034.         /colK exch store /colY exch store
  1035.         /colM exch store /colC exch store
  1036.         /linewidth currentlinewidth XthruCTM store
  1037.         /linecap currentlinecap store
  1038.         /linejoin currentlinejoin store
  1039.         /miterlimit currentmiterlimit store
  1040.         currentdash /dashoff exch store /dasharray exch store
  1041.         /origfontname /InvalidFont store
  1042.         /definefontname /InvalidFont store
  1043.         /fontscale initfontscale store
  1044.         /currfontdict currentfont store
  1045.         currentscreen
  1046.         /screenproc exch store
  1047.         /screenang exch store
  1048.         /screenfreq exch store
  1049.         /cliphash clippath hashpath store    % Wed Dec 28 12:41:07 1988
  1050.     grestore
  1051.     } bdef % initgstate
  1052.     /forcegstate { %def
  1053.     % after save & restore, you may have to explicitly "undo" anything
  1054.     % that was done within the saved context.  Since save & restore
  1055.     % affect all our state variables, we dump anything that is different
  1056.     % from the default graphics state:
  1057.     /CTM [1.01 0 1.01 0 .5 .5] store
  1058.     /compareCTM [1.01 0 1.01 0 .5 .5] store
  1059.     /fontscale initfontscale store
  1060.     /currfontdict null store
  1061.     /gray null store
  1062.     /colC null store
  1063.     % checkgstate % fontstate
  1064.     } bdef % initgstate
  1065.     /checkgstate { %def
  1066.     graphicstate
  1067.     fontstate
  1068.     } def %checkgstate
  1069.     /checkCTM { %def
  1070.     tmpmtx currentmatrix compareCTM matrixeq not {
  1071.          /CTM mtx currentmatrix $normalize store
  1072.         compareCTM currentmatrix pop
  1073.         .345 dup 0 dtransform pop 0 idtransform
  1074.         pop ne dup /rot exch store not optimize and /optim exch store
  1075.     } if
  1076.     } bdef
  1077.     /generalstate { %def
  1078.     stackptr 0 ne { stackshow } if
  1079.     /lastshow false store
  1080.     checkCTM
  1081.     } bdef % generalstate
  1082.     /colorstate { %def
  1083.     mark currentcmykcolor
  1084.     colC colM colY colK 4 { %repeat
  1085.         dup 5 index ne 10 1 roll 8 1 roll
  1086.     } repeat
  1087.     cleartomark or or or {
  1088.         currentcmykcolor
  1089.         /colK exch store /colY exch store
  1090.         /colM exch store /colC exch store
  1091.         colC 0 eq colM 0 eq colY 0 eq and and not { %ifelse % COLOR
  1092.         colC writenum colM writenum colY writenum colK writenum
  1093.         (C) writeop
  1094.         }{ %else                        % GRAY
  1095.         1 colK sub shave writenum (g) writeop
  1096.         } ifelse
  1097.     } if
  1098. %     gray currentgray ne {
  1099. %         /gray currentgray store
  1100. %         gray shave writenum (g) writeop
  1101. %     } if
  1102.     } bdef % colorstate
  1103.     /registerfont { %def
  1104.     dup cachedir exch 20 dict put    % allow 20 point sizes
  1105.     cachedir exch get        % ptsize dict
  1106.     exch fontcount put
  1107.     } bdef
  1108.     /addfontsize { %def
  1109.     cachedir exch get
  1110.     exch fontcount put
  1111.     } bdef
  1112.  
  1113.     /fontstate { %def
  1114.       currentfont null eq not    { %if
  1115.     currentfont dup /ScaleMatrix known not { pop }{ %ifelse
  1116.         begin
  1117.          % determine if anything has changed:
  1118.         tmpmtx currentmatrix compareCTM matrixeq not
  1119.         currfontdict currentfont ne or
  1120.         ScaleMatrix fontscale ne or
  1121.         { %if
  1122.           % get and set new font names
  1123.             /origfontname
  1124.             /FontInfo where { %ifelse
  1125.                 pop FontInfo /realname known
  1126.                 { FontInfo /realname get }{ % ifelse
  1127.                   /FontName where {pop FontName}{/Unknown} ifelse
  1128.                 } ifelse
  1129.             }{ %else
  1130.                 /FontName where {pop FontName}{/Unknown} ifelse
  1131.             } ifelse
  1132.             store
  1133.             /definefontname
  1134.             /FontName where { pop FontName }{ /Unknown } ifelse
  1135.             FontDirectory { %forall
  1136.                 currentdict eq
  1137.                 { exch pop exit }
  1138.                 { pop } ifelse
  1139.             } forall
  1140.             store
  1141.             origfontname hidefontname
  1142.          % check for font reencoding:
  1143.          % The current font is the one required in the distilled
  1144.          % program.  If it is a reeconded font, we must generate
  1145.          % a call to "REMAP", but at the same time let's mark it
  1146.          % so we don't generate too may "REMAP" calls.
  1147.  
  1148.             checksetup generalstate colorstate
  1149.          % worry about reencoding:
  1150.             /FontInfo where { %ifelse
  1151.             pop FontInfo /pleasemap known { %ifelse
  1152.                 FontInfo /pleasemap get cvbool
  1153.             }{ %else
  1154.                 false  % evidently has not been reencoded...
  1155.             } ifelse % leaves a boolean
  1156.             }{ false } ifelse
  1157.             { % if remapping has not been done yet:
  1158.             Encoding hashencoding
  1159.             origfontname findfont /Encoding get hashencoding
  1160.             ne { %ifelse
  1161.                 Encoding hashencoding
  1162.                 STDvec cvnum eq { %ifelse
  1163.                 (stdvec) writestr
  1164.                 origfontname writeRname
  1165.                 origfontname (/) wout writename
  1166.                 ( REMAP) writeop
  1167.                 }{ %else
  1168.                   Encoding hashencoding PAGEvec cvnum eq {
  1169.                   (pagevec) writestr
  1170.                   origfontname writeRname
  1171.                   origfontname (/) wout writename
  1172.                   ( REMAP) writeop
  1173.                   }{ %else
  1174.                   origfontname findfont /Encoding get Encoding
  1175.                   diffencoding writediffencoding
  1176.                   origfontname writeRname
  1177.                   origfontname (/) wout writename
  1178.                   ( RECODE) writeop
  1179.                   } ifelse
  1180.                 } ifelse
  1181.                 /FontInfo where { %if
  1182.                 pop FontInfo /pleasemap known { %if
  1183.                     FontInfo begin
  1184.                         /pleasemap false hidebool
  1185.                     end
  1186.                 } if
  1187.                 } if
  1188.             } if
  1189.             } if % /pleasemap
  1190.          % check font scale change:
  1191.          % This stuff is absolutely horrible....
  1192.             /fontscale ScaleMatrix store
  1193.             fontscale CTM curfontmtx concatmatrix
  1194.             aload pop                % Xscale 0a 0b Yscale 0 0
  1195.             % pop 3 -1 roll pop 3 -1 roll    % X Y 0b 0a [wrong]
  1196.             pop pop 3 1 roll            % X Y 0b 0a
  1197.            % if 2nd and 5th elements are both 0...
  1198.            % and X Y are equal and positive, then you can use
  1199.            % "scalefont", else you have to use "makefont"
  1200.             /0a exch store /0b exch store
  1201.             /X1 exch store /X2 exch store
  1202.              X1 X2            % leave on stack
  1203.             0a 0b eq 0b 0 eq and    % make sure 0's are 0
  1204.              X1 X2 eq and        % X1 and X2 are equal
  1205.              X1 dup abs eq X2 dup abs eq and    % and positive
  1206.              and
  1207.             { %ifelse
  1208.             pop shave    % eliminate unnecessary precision
  1209.              % if you find it in the "font dict cache"....
  1210.             cachedir definefontname known { %ifelse
  1211.                 cachedir definefontname get dup 2 index known {
  1212.                 exch get (F) wout writenum
  1213.                 (F) writeop
  1214.                 }{ %else
  1215.                 pop
  1216.                 /fontcount ++
  1217.                 dup definefontname addfontsize
  1218.                 (/F) wout fontcount writenum %+ cvnum writenum
  1219.                 writenum
  1220.                 origfontname
  1221.                 /FontInfo where { %ifelse
  1222.                     pop FontInfo /pleasemap known { %ifelse
  1223.                     FontInfo /pleasemap get cvbool
  1224.                     }{ false } ifelse % leaves a boolean
  1225.                 }{ false } ifelse
  1226.                 Encoding hashencoding    %new!
  1227.                 origfontname findfont /Encoding get
  1228.                 hashencoding ne and
  1229.                 { %ifelse
  1230.                     writeRname
  1231.                 }{ (/) wout writename } ifelse
  1232.                 (DF) writeop
  1233.                 } ifelse
  1234.             }{ %else if you DON'T find the name in the cache
  1235.                 /fontcount ++
  1236.                 dup definefontname registerfont
  1237.                 (/F) wout fontcount writenum
  1238.                 writenum
  1239.                 origfontname
  1240.                 /FontInfo where { %ifelse
  1241.                 pop FontInfo /pleasemap known { %ifelse
  1242.                     FontInfo /pleasemap get cvbool not
  1243.                 }{ false } ifelse % leaves a boolean
  1244.                 }{ false } ifelse
  1245.                 Encoding hashencoding    %new!
  1246.                 origfontname findfont /Encoding get
  1247.                 hashencoding ne and
  1248.                 { %ifelse
  1249.                 writeRname
  1250.                 }{ (/) wout writename } ifelse
  1251.                 (DF) writeop
  1252.             } ifelse
  1253.             }{ %else
  1254.              % need either "makefont" or rotated coordinate system
  1255.             pop pop curfontmtx
  1256.             dup 4 0. put dup 5 0. put  % no translate
  1257.             writenumarray
  1258.             origfontname
  1259.             /FontInfo where {
  1260.                 pop FontInfo /pleasemap known
  1261.             }{ false } ifelse { %ifelse
  1262.                 writeRname
  1263.             }{ (/) wout writename } ifelse
  1264.             (MF) writeop
  1265.             } ifelse
  1266.             /currfontdict currentfont store
  1267.         } if % anything has changed
  1268.         end
  1269.     } ifelse
  1270.     beginsetup cvbool not {
  1271.         generalstate
  1272.         colorstate
  1273.     } if
  1274.       } if
  1275.     } bdef %fontstate
  1276.  
  1277.     /graphicstate { %def
  1278.     checksetup
  1279.     generalstate
  1280.     colorstate
  1281.     linewidth currentlinewidth XthruCTM ne {
  1282.         /linewidth currentlinewidth XthruCTM store
  1283.         linewidth shave writenum (w) writeop
  1284.     } if
  1285.     linecap currentlinecap ne {
  1286.         /linecap currentlinecap store
  1287.         linecap writenum (setlinecap) writeop
  1288.     } if
  1289.     linejoin currentlinejoin ne {
  1290.         /linejoin currentlinejoin store
  1291.         linejoin writenum (j) writeop
  1292.     } if
  1293.     miterlimit currentmiterlimit ne {
  1294.         /miterlimit currentmiterlimit store
  1295.         miterlimit shave writenum (setmiterlimit) writeop
  1296.     } if
  1297.     currentdash dashoff ne exch dasharray ne or {
  1298.         currentdash /dashoff exch store /dasharray exch store
  1299.         fd ([) writestring
  1300.         dasharray { XthruCTM writenum } forall
  1301.         fd (] ) writestring
  1302.         dashoff XthruCTM writenum (d) writeop
  1303.     } if
  1304.     gsave
  1305.       % don't clip to degenerate paths of any kind:
  1306.         newpath clippath hashpath cliphash ne { %if
  1307.         mark { pathbbox } stopped not {
  1308.             exch 4 -1 roll sub abs 1 gt
  1309.             3 1 roll sub abs 1 gt and { % if
  1310.             writepath
  1311.             (clip newpath) writeop
  1312.             /cliphash hashpath store
  1313.             } if
  1314.         } if cleartomark
  1315.         } if
  1316.     grestore
  1317.     currentscreen
  1318.     /screenproc load ne exch screenang ne or exch screenfreq ne or { %if
  1319.         currentscreen
  1320.         /screenproc exch store
  1321.         /screenang exch store
  1322.         /screenfreq exch store
  1323.         screenfreq writenum screenang writenum writeNL
  1324.         /screenproc load
  1325.         dup type /arraytype eq
  1326.         1 index type /packedarraytype eq or { %ifelse
  1327.         checkallnames
  1328.         }{ pop } ifelse
  1329.         /screenproc load writeproc
  1330.         (setscreen) writeop
  1331.     } if
  1332.     } bdef %graphicstate
  1333.  
  1334. end %adobe_distill
  1335. /setpacking where { pop setpacking } if
  1336. %%EndProcSet
  1337.  
  1338. %%BeginProcSet: distill_optimize 1.0 0
  1339. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  1340. adobe_distill begin
  1341.   % These procedures implement an optimization scheme for recognizing
  1342.   % sequences of "show" operations that could be optimized into calls
  1343.   % to "widthshow" (or just "show" with a longer string body).  In
  1344.   % order to accomplish this, we have implemented a stack to store
  1345.   % string bodies until they are flushed by a font change, a change
  1346.   % in Y coordinate, or an inter-string space that is inconsistent.
  1347.   % When comparing coordinates for equality, anything with the given
  1348.   % tolerance is accepted as being equal (to combat roundoff error).
  1349.     /tolerance .05 ifnotdef
  1350.     /EQ { sub abs tolerance le } bdef
  1351.     /stack 250 array def
  1352.     /stackptr 0 def
  1353. /setpacking where { pop currentpacking true setpacking } if
  1354.     /push { %def
  1355.     stackptr 0 eq { % if
  1356.         currentpoint thruCTM
  1357.         /showY exch store /showX exch store
  1358.     } if
  1359.     /stackptr stackptr 1 add store
  1360.       stackptr 249 ge { (STACK OVERFLOW!) = flush exit } if
  1361.     stack stackptr 3 -1 roll put
  1362.     } bdef
  1363.     /pull { %def
  1364.     stack stackptr get
  1365.     /stackptr stackptr dup 0 gt { 1 sub } if store
  1366.     } bdef
  1367.  
  1368.     /*save systemdict /save get def
  1369.     /save { % def
  1370.     stackshow    % in case there's anything pending....
  1371.     *save
  1372.     } bdef
  1373.  
  1374.     /*restore systemdict /restore get def
  1375.     /restore { % def
  1376.     % after save & restore, you may have to explicitly "undo" anything
  1377.     % that was done within the saved context.  Since save & restore
  1378.     % affect all distillery state variables, we dump anything different
  1379.     % from the default graphics state:
  1380.     stackshow    % in case there's anything pending....
  1381.       currentlinecap    % 5
  1382.       currentlinewidth    % 4
  1383.       currentgray        % 3
  1384.       currentmiterlimit    % 2
  1385.       currentlinejoin    % 1
  1386.         6 -1 roll *restore
  1387.       setlinejoin        % 1
  1388.       setmiterlimit        % 2
  1389.       setgray        % 3
  1390.       setlinewidth        % 4
  1391.       setlinecap        % 5
  1392. %    initgstate
  1393.     forcegstate % checkgstate %graphicstate
  1394.     (after restore) d=
  1395.     } bdef
  1396.  
  1397.     /stackshow { %def
  1398.     stackptr 0 ne { %if
  1399.         (stackshow: ) d= 1 1 stackptr { (  ) pr= stack exch get d= } for
  1400.         stackptr 1 eq { %ifelse
  1401.         %- if there is only one string, use "show":
  1402.         pull writePSstring
  1403.         showX showY writepair (T) writeop
  1404.         }{ %else
  1405.         %- otherwise, build single string (with \b to use W):
  1406.         diffX 0 EQ not { % if
  1407.             gsave        % figure out widthshow value
  1408.             currfont setfont
  1409.             diffX (\b) stringwidth CTM dtransform pop sub
  1410.             grestore
  1411.             writenum (0) writestr (\b) 0 get writenum
  1412.             (\\b)    % padding character
  1413.         }{ % else
  1414.             ()        % empty padding character
  1415.         } ifelse
  1416.         (\() wout
  1417.         1 1 stackptr 1 sub { % for
  1418.             stack exch get wordfix dup wout
  1419.         } for
  1420.         pop        % padding character
  1421.         pull wordfix
  1422.         (\)) wout writeNL
  1423.         showX showY writepair
  1424.         %- if diffX is 0, don't use "widthshow":
  1425.         diffX 0 EQ { (T) }{ (W) } ifelse writeop
  1426.         } ifelse
  1427.         /stackptr 0 store
  1428.     } if
  1429.     } bdef
  1430.  
  1431.     /setcurrpoint { %def
  1432.     currentpoint thruCTM
  1433.     /currY exch store /currX exch store
  1434.     } bdef % setcurrpoint
  1435.  
  1436. end %adobe_distill
  1437. /setpacking where { pop setpacking } if
  1438. %%EndProcSet
  1439.  
  1440. %%BeginProcSet: distill_paintops 1.0 0
  1441. /setpacking where { pop currentpacking true setpacking } if
  1442. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  1443. adobe_distill begin
  1444.  
  1445.   % text operators
  1446.     /sameYcoords { %def
  1447.       % this is pulled out of the "show" proc for readability; it is
  1448.       % not used anywhere else
  1449.     currentfont currfont ne { %ifelse
  1450.         stackshow fontstate push
  1451.     }{ %else
  1452.         currentpoint thruCTM pop
  1453.         currX sub dup diffX EQ { %ifelse
  1454.         pop     % dup'ed value
  1455.         push
  1456.         }{ %else
  1457.         diffX -1 eq { %ifelse
  1458.             /diffX exch store push
  1459.         }{ % else
  1460.             pop stackshow fontstate
  1461.             /diffX -1 store push
  1462.         } ifelse
  1463.         } ifelse
  1464.     } ifelse
  1465.     } bdef
  1466.     /show { %def
  1467.     checkCTM currentpoint thruCTM ?box
  1468.     optim { %ifelse
  1469.         dup length 0 eq { pop } { %ifelse
  1470.         dup            % save string for use at the end
  1471.         lastshow not { %ifelse
  1472.             stackshow fontstate
  1473.             /currfont currentfont store
  1474.             push
  1475.             /diffX -1 store
  1476.         }{ % else
  1477.           % don't optimize if matrix is different...
  1478.             tmpmtx currentmatrix compareCTM matrixeq
  1479.             currentpoint thruCTM exch pop
  1480.             currY eq and { %ifelse        Y = Y
  1481.             sameYcoords
  1482.             }{ %else currY ne
  1483.             stackshow    % flush the pending show stack
  1484.             fontstate
  1485.             push        % the string (and set showX, showY)
  1486.             /diffX -1 store
  1487.             } ifelse
  1488.             /currfont currentfont store
  1489.         } ifelse %lastshow
  1490.         currentfont /FontType known {
  1491.             currentfont /FontType get 3 eq {
  1492.             end show adobe_distill begin
  1493.             }{ show } ifelse
  1494.         }{ end show adobe_distill begin } ifelse
  1495.         setcurrpoint
  1496.         /lastshow true store
  1497.         } ifelse % if length is not 0
  1498.     }{ % else
  1499.         dup length 0 eq { pop } { %ifelse
  1500.         fontstate
  1501.         dup writePSstring currentpoint writeTpair
  1502.         (T) writeop
  1503.         currentfont /FontType known {
  1504.             currentfont /FontType get 3 eq {
  1505.             end show adobe_distill begin
  1506.             }{ show } ifelse
  1507.         }{ end show adobe_distill begin } ifelse
  1508.         } ifelse % if operand is not null string
  1509.     } ifelse
  1510.     currentpoint thruCTM ?box
  1511.     } bdef
  1512.  
  1513.     /widthshow { %def
  1514.     checkCTM currentpoint thruCTM ?box
  1515.     optim { %ifelse
  1516.         dup length 0 eq { 4{pop}repeat } { %ifelse
  1517.         4 copy pop pop
  1518.         1 index EQ exch 0.0 EQ and { % ifelse
  1519.             fontstate
  1520.             4 1 roll pop pop pop
  1521.             show    % make sure it's not "bound"
  1522.         }{ %else
  1523.             fontstate
  1524.             4 copy
  1525.             4 2 roll dthruCTM writepair %exch writeXnum writeYnum
  1526.             exch writenum writePSstring currentpoint writeTpair
  1527.             (W) writeop
  1528.             currentfont /FontType known {
  1529.             currentfont /FontType get 3 eq {
  1530.                 end widthshow adobe_distill begin
  1531.             }{ widthshow } ifelse
  1532.             }{ end widthshow adobe_distill begin } ifelse
  1533.         } ifelse
  1534.         } ifelse
  1535.     }{ %else
  1536.         % Cx Cy char (string) widthshow
  1537.         dup length 0 eq { 4{pop}repeat } { %ifelse
  1538.         fontstate
  1539.         4 copy
  1540.         % 4 -2 roll exch writeXnum writeYnum exch writenum
  1541.         4 -2 roll dthruCTM writepair exch writenum
  1542.         writePSstring currentpoint writeTpair
  1543.         (W) writeop
  1544.         currentfont /FontType known {
  1545.             currentfont /FontType get 3 eq {
  1546.             end widthshow adobe_distill begin
  1547.             }{ widthshow } ifelse
  1548.         }{ end widthshow adobe_distill begin } ifelse
  1549.         } ifelse
  1550.     } ifelse
  1551.     currentpoint thruCTM ?box
  1552.     } bdef
  1553.  
  1554.     /ashow { %bdef
  1555.     checkCTM currentpoint thruCTM ?box
  1556.     optim { %ifelse
  1557.         dup length 0 eq { pop pop pop } { %ifelse
  1558.         3 copy pop
  1559.         1 index EQ exch 0.0 EQ and { % ifelse
  1560.             fontstate
  1561.             3 1 roll pop pop
  1562.             show    % make sure it's not "bound"
  1563.         }{ %else
  1564.             fontstate
  1565.             3 copy
  1566.             3 1 roll dthruCTM writepair
  1567.             writePSstring currentpoint writeTpair
  1568.             (A) writeop
  1569.             currentfont /FontType known {
  1570.             currentfont /FontType get 3 eq {
  1571.                 end ashow adobe_distill begin
  1572.             }{ ashow } ifelse
  1573.             }{ end ashow adobe_distill begin } ifelse
  1574.         } ifelse
  1575.         } ifelse
  1576.     }{ %else
  1577.         dup length 0 eq { pop pop pop } { %ifelse
  1578.         fontstate
  1579.         3 copy
  1580.         3 1 roll dthruCTM writepair % exch writeXnum writeYnum
  1581.         writePSstring currentpoint writeTpair
  1582.         (A) writeop
  1583.         currentfont /FontType known {
  1584.             currentfont /FontType get 3 eq {
  1585.             end ashow adobe_distill begin
  1586.             }{ ashow } ifelse
  1587.         }{ end ashow adobe_distill begin } ifelse
  1588.         } ifelse
  1589.     } ifelse
  1590.     currentpoint thruCTM ?box
  1591.     } bdef
  1592.  
  1593.     /awidthshow { %def
  1594.     % Cx Cy 32 Ax Ay (string) awidthshow
  1595.     checkCTM currentpoint thruCTM ?box
  1596.     optim { %def
  1597.         dup length 0 eq { 6{pop}repeat } { %ifelse
  1598.         fontstate
  1599.         6 copy 6 1 roll
  1600.         1 index EQ exch 0.0 EQ and { %ifelse
  1601.             4 1 roll 1 index eq exch 0.0 eq and { %leaves 32 (str)
  1602.             8 1 roll 7 { pop } repeat
  1603.             show    % make sure it's not "bound"
  1604.             }{ %else
  1605.             pop pop 3 1 roll pop pop
  1606.             widthshow    % make sure it's not "bound"
  1607.             } ifelse
  1608.         }{ %else
  1609.             pop pop pop pop 6 copy 6 -3 roll pop
  1610.             1 index EQ exch 0.0 EQ and { % ifelse
  1611.             9 3 roll 6 { pop } repeat
  1612.             ashow    % make sure it's not "bound"
  1613.             }{ %else
  1614.             pop pop pop 6 copy
  1615.             6 -2 roll dthruCTM writepair
  1616.             4 -1 roll writenum 3 1 roll dthruCTM writepair
  1617.             writePSstring currentpoint writeTpair
  1618.             (AW) writeop
  1619.             currentfont /FontType known {
  1620.                 currentfont /FontType get 3 eq {
  1621.                 end awidthshow adobe_distill begin
  1622.                 }{ awidthshow } ifelse
  1623.             }{ end awidthshow adobe_distill begin } ifelse
  1624.             } ifelse
  1625.         } ifelse
  1626.         } ifelse
  1627.     }{ %else
  1628.         dup length 0 eq { 6{pop}repeat } { %ifelse
  1629.         fontstate
  1630.         6 copy
  1631.         % 6 -2 roll exch writeXnum writeYnum
  1632.         % 4 -1 roll writenum 3 -1 roll writeXnum exch writeYnum
  1633.         6 -2 roll dthruCTM writepair
  1634.         4 -1 roll writenum 3 1 roll dthruCTM writepair
  1635.         writePSstring currentpoint writeTpair
  1636.         (AW) writeop
  1637.             currentfont /FontType known {
  1638.             currentfont /FontType get 3 eq {
  1639.                 end awidthshow adobe_distill begin
  1640.             }{ awidthshow } ifelse
  1641.             }{ end awidthshow adobe_distill begin } ifelse
  1642.         } ifelse
  1643.     } ifelse
  1644.     currentpoint thruCTM ?box
  1645.     } bdef
  1646.  
  1647.    % graphics operators
  1648.     /fillguts { %def
  1649.     (starting fill) d=
  1650.     generalstate
  1651.     graphicstate
  1652.     writepath
  1653.     ischarpath { % if
  1654.         pathstr length 0 gt {
  1655.         pathX writenum pathY writenum (m) writeop
  1656.         pathstr writePSstring (false charpath) writeop
  1657.         } if
  1658.         gstates 0 le {
  1659.         /ischarpath false store
  1660.         /closed false store
  1661.         } if
  1662.     } if
  1663.     } bdef
  1664.  
  1665.     /fill { %def
  1666.     fillguts
  1667.     ?simplepath {
  1668.         simplepath aload pop
  1669.         4 2 roll writepair (moveto) writeop writepair (lineto) writeop
  1670.         /?simplepath false store
  1671.     } if
  1672.     (f) writeop
  1673.     fill
  1674.     } bdef
  1675.     /eofill { %def
  1676.     fillguts
  1677.     ?simplepath { %ifelse
  1678.         simplepath aload pop
  1679.         4 2 roll writepair (moveto) writeop writepair (lineto) writeop
  1680.         /?simplepath false store
  1681.     } if
  1682.     (eofill) writeop
  1683.     eofill
  1684.     } bdef
  1685.  
  1686.     /stroke { %def
  1687.     fillguts
  1688.     ?simplepath { %ifelse
  1689.         generalstate graphicstate
  1690.         simplepath aload pop writepair writepair (l) writeop
  1691.         /?simplepath false store
  1692.     }{ % else
  1693.         closed { (cp ) wout } if
  1694.         (s) writeop
  1695.     } ifelse
  1696.     stroke
  1697.     } bdef
  1698.  
  1699.     /clip { %def
  1700.     /lastshow false store
  1701.     clip
  1702.     } bdef
  1703.     /eoclip { clip } def
  1704.     /imageguts { % def
  1705.     graphicstate
  1706.     /imageproc exch store
  1707.     /imagematrix exch store
  1708.     /imagedepth exch store
  1709.     /imageheight exch store
  1710.     /imagewidth exch store
  1711.      % set up the call to "image" in the output file:
  1712.     (/imagesave save def) writeop
  1713.     CTM writenumarray (concat) writeop
  1714.     0 0 thruCTM ?box
  1715.     imagewidth imagedepth dup type /booleantype eq { pop 1 } if
  1716.     div imageheight imagematrix itransform thruCTM ?box
  1717.     (/imagebuff) writestr
  1718.     imagedepth dup type /booleantype eq { pop 1 } if
  1719.     imagewidth mul dup dup 8 idiv 8 mul eq {8 idiv}{8 idiv 1 add} ifelse
  1720.     writenum ( string def) writeop
  1721.      % invoke "image" with correct args in output file:
  1722.     imagewidth writenum imageheight writenum
  1723.     imagedepth (     ) cvs writestr
  1724.     imagematrix writenumarray
  1725.     } bdef
  1726.     /image { %def    % width height depth matrix { proc } :
  1727.     imageguts
  1728.     ({ currentfile imagebuff readhexstring pop } image) writeop
  1729.     imagewidth imageheight imagedepth imagematrix
  1730.     { imageproc dup fd exch writehexstring writeNL } image
  1731.     (imagesave restore) writeop
  1732.     } bdef
  1733.     /imagemask { % def    % width height depth matrix { proc } :
  1734.     imageguts
  1735.     ({ currentfile imagebuff readhexstring pop } imagemask) writeop
  1736.     imagewidth imageheight imagedepth imagematrix
  1737.     { imageproc dup fd exch writehexstring writeNL } imagemask
  1738.     (imagesave restore) writeop
  1739.     } bdef
  1740.     % don't actually print the pages...   Fri Feb 17 13:13:10 1989
  1741.     % /*showpage systemdict /showpage get def
  1742.     /*showpage where { pop }{ %ifelse
  1743.     /*showpage /showpage load def
  1744.     } ifelse
  1745.     /showpage { %def
  1746.     stackshow
  1747.     pagecount cvnum scratch cvs wout ( ENDPAGE\n) wout
  1748.     /lastshowpage true hidebool
  1749.     /begunpage false hidebool
  1750.     /PAGEvec 0 hideval
  1751.     *showpage
  1752.     (%%PageTrailer) writeop
  1753.     (%%PageFonts: ) wout
  1754.     pfontcount cvnum 0 eq { writeNL }{ %else
  1755.         pfontcount cvnum 200 lt { %ifelse
  1756.         pagefonts 0 pfontcount cvnum getinterval writeop
  1757.         }{ %else
  1758.         pagefonts (\040) search not { writeop }{ %else
  1759.             writeop    % first one without the %%+
  1760.             { %loop
  1761.             search { (%%+ ) wout writeop }{ %else
  1762.                 (\000) search { writeop pop pop }{ pop0} ifelse
  1763.                 exit
  1764.             } ifelse
  1765.             } loop
  1766.         } ifelse
  1767.         } ifelse
  1768.     } ifelse
  1769.     0 1 pfontcount cvnum { pagefonts exch 0 put } for
  1770.     /pfontcount 0 hideval
  1771.     LLx 10000 eq LLy 10000 eq or URx -1 eq URy¬-10000 eq or or not {
  1772.         (%%PageBoundingBox: ) wout
  1773.           LLx cvnum writenum LLy cvnum writenum
  1774.           URx cvnum writenum URy cvnum writenum writeNL
  1775.         pageBBox-docBBox
  1776.     } if
  1777.     /LLx 10000 hideval  /LLy 10000 hideval
  1778.     /URx -10000 hideval /URy -10000 hideval
  1779.     % checksetup
  1780.     } bdef
  1781.     /*moveto systemdict /moveto get def
  1782.     /*pathbbox systemdict /pathbbox get def
  1783.     /"athbbox { %def
  1784.     ischarpath { %ifelse
  1785.         gsave
  1786.         { currentpoint } stopped { 0 0 } if *moveto
  1787.         pathstr false charpath flattenpath *pathbbox
  1788.         grestore
  1789.     }{ %else
  1790.         *pathbbox
  1791.     } ifelse
  1792.     } bdef
  1793.     /gsave { % def
  1794.     /gstates gstates 1 add store
  1795.     ∫save
  1796.     } bdef
  1797.     /grestore { % def
  1798.     gstates 0 gt { %if
  1799.         /gstates Òstates 1 sub store
  1800.         gstates chßpathgs€∑te lt { /ischarQath fa˚3e store } if
  1801.     } if
  1802.     grestore
  1803.     } bde    m    /c˛rpath { %def
  1804.     %¸need tÿÍmake sre thatwhen "s∂˚oke" or "fill"§Bomes aŒ!ng
  1805.     %     hat the"charpa8Ê" elemnts arefEn the %)ght plPce in t&Æ path.µy
  1806.     Ù- w–’tepath8checkg≥£ate
  1807.     /ipcharpa¡• true s\ore
  1808.     /Ωarpath‘µtate gsùates sQore
  1809.     /pÜhbooy exch sto•o
  1810.     /patuItr exch store
  1811. √è curreÚBpoin± } stoppe¶{ 0 0 ï if tÀruCTM
  1812.     /py†hY exc5‹stor… /pathX e—◊h store¬    pat·˚tr strinûRidth rmveto–]   } bde)µ    /neÍpath∑£ %def
  1813.      …I gst{tes 0 lW { /ischarath false stô~e } if
  1814.     Á  neÏpath
  1815.   Ù»} bdef
  1816.  
  1817. atd %aÃobe_dis⁄ ll
  1818. /setp≈ˇkingûwhere {dop setpacçing «8if
  1819. %%Efi$ProcSet: -isti‡À_paintıs 1.0
  1820.  
  1821. %%Iegin_ˇocSet:8_istill_guessfoëm 1.0
  1822. 0®tpacking where˜ˇ pop cÈïrentpavking tré® setpa€„ing } ~
  1823. /adob5ÏdistilÍØdup whqre { poJPpop }{œ˙65 200}hdd dâcdef } inelse
  1824. a:(be_disÙ6ll begI„
  1825.     /!uefinefo•t systeWdict / finefo¸$ get def
  1826.     /Jñfinefon W %def     % makäa dictΔonary into whicŒ%to putßÃhings
  1827.     % put tûG ORIGIØAL name of the int into
  1828. that dictionìry
  1829.     % put the original ùID in that dictionary, ≈or easy comparison
  1830.     dupãKFontType get 3 eq { %iÛ'lse
  1831.         dup bcgin
  1832.         i+æludeuserfonts ˚
  1833.             C`rrentdict writÌANY
  1834.          øë 1 index write¬NY (excA˙definefont pop) writeoüj        } if
  1835.         currenndict /NÕntInfo known {
  1836. &        / óntInfo 5 dict Èef
  1837.           zFontInfo begin™            /rea´ame 2 pndex ded            /plÀsemap –agicboo•õdef
  1838.         Ù“pleaseæap fals¨ hXdebo¶°
  1839.            ïend
  1840.         }©]f
  1841.         Önd
  1842.     }{∏†else
  1843.     zM  /Dfonä exch =˛ore
  1844.      ⁄This miPht be ãe firs2time we've eve7öseen aÈbew
  1845.      % Encodin A  If s≠ï letßs guess t˝qt we'ä5asee Mots
  1846.      % mI0e of t∂T vecor, and gëe it thë nam "stdvec"‡‘         \Üont &$«in
  1847.         %goœ FontTye 1 Ä˙ STDvec ’Cnum 0 eq andJˆ        –[Dvec cvnum 0q
  1848.         Encod¬ng SYandardE@»oding ne‰πnd {õ%if
  1849. m     ;Δ /STDvecAÊncod»[g hashencoding hqevalä⁄        fΡ(/stdvec<Ú) *w
  1850. itestri¸P
  1851.             STıvec
  1852. r    St`≠dardEncoding h)Àhencodflfig eq { %ifelse{Ó        fd (&9an˝ardncodingk *writ&tring
  1853.             }{@›el–e
  1854.     ÈEncodiËg writew)mearra
  1855.             & ifelseâ}        fd (def\nÍ *write]$ring
  1856.         µ   cheá†setup
  1857.     }{ %elsÃ
  1858.           —ñπgcr FoíºTypï 1 eq STDvΠcvnum ® eq and
  1859.             ÒåDvec c‚num 0 eq
  1860.             `≈coding]StandardEncoding ne and { %if
  1861.             /PAGEvec Encoding hashencoding hideval
  1862.             fd (/pagevec\n) *writestring
  1863.             PAGEvec
  1864.             StandardEncoding hashencoding eq { %ifelse
  1865.                 fd (StandardEncoding ) *writestring
  1866.             }{ %else
  1867.                 Encoding writenamearray
  1868.             } ifelse
  1869.             fd (def\n) *writestring
  1870.             checksetup
  1871.             } if
  1872.         } ifelse
  1873.         end¥     % try to find the "real" font in FontDirectory from which this
  1874.      % font was derived, assuming it was reencoded....
  1875.         /tem`fontname /Couâier store
  1876.         /tempfontname /UnKnownFont store
  1877.         FontDirectory { %forall
  1878.         /Ffont exch store /Fname exch store
  1879.         % if the font was already touched, ignore it:
  1880.         Ffont /FontInfo known { %ifelse
  1881.             Ffont /FontInfo get /realname known not
  1882.         }{ true } ifelse    % leaves boolean
  1883.         { % if
  1884.             % if UniqueID's match, grab it!
  1885.            ¢Dfont /UniqueID known Ffont /UniqueID known and {
  1886.             Dfont /UniqueID get Ffont /UniqueID get eq {
  1887.                 /tempfontname Fname store exit
  1888.             } if
  1889.             } if
  1890.         } if % /realname is not there
  1891.         } forall
  1892.         tempfontname /UnKnownFont eq { %if
  1893.           Dfont begin
  1894.         FontDirectory { %forall
  1895.           /Ffont exch store /Fname exch store
  1896.           % if CharStrings match, then compare FontMatrix.  If
  1897.           % FontMatrix matches or the *second* elements match,
  1898.           % (it might be oblique), then grab it.
  1899.           FontType 1 eq {
  1900.             Dfont/CharStrings known Ffont/CharStrings known and {
  1901.               Dfont/CharStrings get Ffont/CharStrings get eq {
  1902.             Dfont/FontMatrix known Ffont/FontMatrix known and {
  1903.               Dfont/FontMatrix get Ffont/FontMatrix get
  1904.               2 copy eq  3 1 roll
  1905.               2 get exch 2 get eq or {
  1906.                   /tempfontname Fname store exit
  1907.               } if
  1908.             } if
  1909.               } if
  1910.             } if
  1911.           } if
  1912.         } forall
  1913.           end
  1914.         } if
  1915.         tempfontname /UnKnownFont eq { %if
  1916.           FontDirectory { %forall
  1917.         /Ffont exch store /Fname exch store
  1918.           % if everything matches but some keys, grab it
  1919.           true    % start with "true" on stack
  1920.           Dfont { %forall
  1921.             exch dup /Encoding eq 1 index /FID eq or { %ifelse
  1922.             pop pop
  1923.             }{ % else
  1924.             dup Ffont exch known {
  1925.                 Ffont exch get ne { pop false exit } if
  1926.             }{ pop pop } ifelse
  1927.             } ifelse
  1928.           } forall
  1929.           % use either "true" that was there, or "false" from loop
  1930.           { %if
  1931.               /tempfontname Fname store exit
  1932.           } if
  1933.           } forall
  1934.         } if
  1935.          tempfontname /UnKnownFont eq {
  1936.         Dfont /Encoding get StandardEncoding eq
  1937.         substitutefonts or { %ifelse
  1938.           % If there is no comparable fontdict already there, and
  1939.           % if this is of FontType 1 and has StandardEncoding,
  1940.           % we guess that this is a downloadable font, and ignore it
  1941.             Dfont /FontName known {
  1942.             /tempfontname Dfont /FontName get store
  1943.             }{
  1944.             /tempfontname /Courier store
  1945.             } ifelse
  1946.             (%substituting ) wout tempfontname writename writeNL
  1947.             messages {
  1948.             (substituting: ) print tempfontname ==
  1949.             } if
  1950.             Dfont    % needed by *definefont below...
  1951.         }{ %else
  1952.             (ERROR: Couldn't find original fontdict to match: ) print
  1953.             Dfont /FontName get == flush
  1954.             (Fonts in FontDirectory include:) =
  1955.             FontDirectory { pop (\040) print == } forall flush
  1956.             stop
  1957.         } ifelse
  1958.         } if
  1959.         Dfont dup begin
  1960.         /FontInfo 5 dict def
  1961.         FontInfo begin
  1962.             /realname tempfontname def
  1963.             /pleasemap magicbool def
  1964.             /pleasemap
  1965.             tempfontname findfont /Encoding get
  1966.             StandardEncoding eq
  1967.             hidebool
  1968.         end
  1969.         end
  1970.     } ifelse
  1971.     *definefont
  1972.     } bdef
  1973.  
  1974. end %adobe_distill
  1975. /setpacking where { pop setpacking } if
  1976. %%EndProcSet: distill_guessfont 1.0
  1977.  
  1978. %%BeginProcSet: hacks 0.5
  1979.   % defeat the "transform round exch round exch itransform" trick:
  1980.     /round { } def
  1981.     /transform { dup type /arraytype eq { pop } if } bdef
  1982.     /itransform { dup type /arraytype eq { pop } if } bdef
  1983.   % redefine control-D:
  1984.     (\004) { (\n%%EOF) writeop } def
  1985. %%EndProcSet: hacks 0.5
  1986.  
  1987.